<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#include "../common/header.ftl"/>

</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
            <#-- 往数据模型中填充一个属性 -->
            <#assign menu="travel"/>
            <#include "../common/menu.ftl"/>
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">待审核游记列表</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/travel/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <select name="state" class="form-control">
                    <option value="1">待审核</option>
                    <option value="-1">已拒绝</option>
                </select>
                <a role="button" class="btn btn-success searchBtn">
                    <span class="glyphicon glyphicon-search"></span>查询
                </a>
            </form>
            <script>
                $("select[name='state']").val(${qo.state});
            </script>
            <table class="table table-striped table-hover" >
                <thead>
                <tr>
                    <th>编号</th>
                    <th>标题</th>
                    <th>封面</th>
                    <th>地点</th>
                    <th>作者</th>
                    <th>状态</th>
                    <th></th>
                </tr>
                </thead>
                <#list pageInfo.list as entity>
                    <tr>
                       <td>${entity_index + 1}</td>
                       <td>${entity.title}</td>
                       <td><img src="${entity.coverUrl}" style="width: 30px"></td>
                       <td>${entity.place.name}</td>
                       <td>${entity.author.nickName!}</td>
                       <td>${entity.stateName!}</td>
                        <td>
                            <a role="button" class="btn btn-xs btn-default changeStatusBtn" data-id='${entity.id}' data-uid='${entity.author.id}' data-state="2">
                                <span class="glyphicon glyphicon-pencil"></span>发布
                            </a>
                            <a role="button" class="btn btn-xs btn-danger changeStatusBtn" data-id='${entity.id}' data-uid='${entity.author.id}' data-state="-1">
                                <span class="glyphicon glyphicon-trash"></span>拒绝
                            </a>
                            <a role="button" class="btn btn-xs btn-success lookBtn" data-content='${entity.travelContent.content}'>
                                <span class="glyphicon glyphicon-eye-open"></span>查看文章
                            </a>
                        </td>
                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl"/>
        </div>
    </div>
</div>
<div class="modal fade" id="contentModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">文章内容</h4>
            </div>
            <div class="modal-body text">

            </div>

        </div>
    </div>
</div>
<script>
    $(function () {
        //给查询按钮绑定点击事件
       $(".searchBtn").click(function () {
           //提交表单
           $("#searchForm").submit();
       });
       //发布和拒绝按钮的点击事件
       $(".changeStatusBtn").click(function () {
           //获取当前按钮绑定的自定义属性  游记的id
           var id = $(this).data("id");
           //获取当前按钮绑定的要修改成什么状态的参数值
           var state = $(this).data("state");
           //作者
           var authorId=$(this).data("uid");
           console.log(authorId);
           //发送请求,将游记的id和要改成的状态携带过去
           $.get("/travel/changeStatus.do",{id:id,state:state,'author.id':authorId},function(data) {
               //成功则刷新页面
               if (data.success) {
                   reload();
               }
           });
       });
        //模态框按钮的点击事件
        $(".lookBtn").click(function () {
            //获取按钮上绑定的内容,并且作为HTML填充到模态框的body
            var c = $(this).data("content");
            $(".text").html(c);
            $("#contentModal").modal("show");
        });
    });
</script>
<style>
    #contentModal img{
        width: 100%;
    }
</style>
</body>
</html>